<template>
    <view>
        <!--标题和返回-->
		<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
			<block slot="backText">返回</block>
			<block slot="content">边坡数据</block>
		</cu-custom>
		 <!--表单区域-->
		<view>
			<form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">地理位置：</text></view>
                  <input  placeholder="请输入地理位置" v-model="model.position"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">省：</text></view>
                  <input  placeholder="请输入省" v-model="model.province"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">市：</text></view>
                  <input  placeholder="请输入市" v-model="model.city"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">区县：</text></view>
                  <input  placeholder="请输入区县" v-model="model.county"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">乡镇：</text></view>
                  <input  placeholder="请输入乡镇" v-model="model.town"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">村：</text></view>
                  <input  placeholder="请输入村" v-model="model.village"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">组：</text></view>
                  <input  placeholder="请输入组" v-model="model.team"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">经度：</text></view>
                  <input type="number" placeholder="请输入经度" v-model="model.latitude"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">纬度：</text></view>
                  <input type="number" placeholder="请输入纬度" v-model="model.longitude"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">户主姓名：</text></view>
                  <input  placeholder="请输入户主姓名" v-model="model.householder"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡类型：</text></view>
                  <input  placeholder="请输入切坡类型" v-model="model.slopeType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">土层松散程度：</text></view>
                  <input  placeholder="请输入土层松散程度" v-model="model.soilLooseness"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">上覆土体类型：</text></view>
                  <input  placeholder="请输入上覆土体类型" v-model="model.overlyingSoilType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">岩体特征：</text></view>
                  <input  placeholder="请输入岩体特征" v-model="model.rockCharacteristics"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">裂隙发育程度：</text></view>
                  <input  placeholder="请输入裂隙发育程度" v-model="model.fractureDevelopmentDegree"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡高度：</text></view>
                  <input  placeholder="请输入切坡高度" v-model="model.cutSlopeHeight"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡坡度：</text></view>
                  <input  placeholder="请输入切坡坡度" v-model="model.cutSlopeGradient"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡坡形：</text></view>
                  <input  placeholder="请输入切坡坡形" v-model="model.cutSlopeShape"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">自然斜坡坡度：</text></view>
                  <input  placeholder="请输入自然斜坡坡度" v-model="model.naturalSlopeGradient"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">岩组类型：</text></view>
                  <input  placeholder="请输入岩组类型" v-model="model.rockType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">植被覆盖率：</text></view>
                  <input  placeholder="请输入植被覆盖率" v-model="model.vegetationCoverage"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">已有治理措施：</text></view>
                  <input  placeholder="请输入已有治理措施" v-model="model.governanceMeasures"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡墙距：</text></view>
                  <input  placeholder="请输入切坡墙距" v-model="model.slopeWallDistance"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡宽度：</text></view>
                  <input  placeholder="请输入切坡宽度" v-model="model.cutSlopeWidth"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡时间：</text></view>
                  <input  placeholder="请输入切坡时间" v-model="model.cutSlopeTime"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">是否有人居：</text></view>
                  <input  placeholder="请输入是否有人居" v-model="model.resident"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁人口：</text></view>
                  <input  placeholder="请输入威胁人口" v-model="model.threatPopulation"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁房屋结构：</text></view>
                  <input  placeholder="请输入威胁房屋结构" v-model="model.threatHouse"/>
                </view>
              </view>
				<view class="padding">
					<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
						<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
					</button>
				</view>
			</form>
		</view>
    </view>
</template>

<script>
    import myDate from '@/components/my-componets/my-date.vue'

    export default {
        name: "GmSlopeDataForm",
        components:{ myDate },
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
				CustomBar: this.CustomBar,
				NavBarColor: this.NavBarColor,
				loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/gmslopedata/gmSlopeData/queryById",
                  add: "/gmslopedata/gmSlopeData/add",
                  edit: "/gmslopedata/gmSlopeData/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
				this.$http.post(url,myForm).then(res=>{
				   console.log("res",res)
				   this.loading = false
				   this.$Router.push({name:this.backRouteName})
				}).catch(()=>{
					this.loading = false
				});
            }
        }
    }
</script>
